<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>websocket连接</h1>
<script>
    const token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjYyNTE2OTc1LCJqdGkiOiI0OWViN2I3ZDdiZjg0ZTAzYTJiMmYyNjhkMWRiODU3MiIsInVzZXJfaWQiOjE0NDcwODI3NjI0NzY0NTM4OTV9.4Bw-HzVzV-vtzKUGzzu0JhBK_D1C4yowO_DcA6voOBE"

    const chatSocket = new WebSocket('ws://' + window.location.host + '/ws/service?token=' + token);
    {# 接收数据 #}
    chatSocket.onmessage = function (e) {
        const data = JSON.parse(e.data);
        console.log(data)
    };
    {# 关闭时触发 #}
    chatSocket.onclose = function (e) {
        console.log(e);
    };
</script>
</body>
</html>